package cn.com.yunhe.service.impl;

import cn.com.yunhe.bean.CCarGuobiao;
import cn.com.yunhe.dao.CCarGuobiaoMapper;
import cn.com.yunhe.service.CCarGuobiaoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.springframework.stereotype.Service;


import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author: 赵长松
 * @Date: 2019/1/9 10:08
 * @Version 1.0
 */
@Service
public class CCarGuobiaoServiceImpl extends ServiceImpl<CCarGuobiaoMapper, CCarGuobiao> implements CCarGuobiaoService {
    @Resource
    private CCarGuobiaoMapper mapper;

    @Override
    public Integer addCCarGuobiao(CCarGuobiao cCarGuobiao) {//插入新排放标准
        return mapper.insert(cCarGuobiao);
    }

    @Override
    public List<CCarGuobiao> queryAllCarGuobiao(Map map) {//查询排放标准
        QueryWrapper<CCarGuobiao> cCarGuobiaoQueryWrapper = new QueryWrapper<>();
        cCarGuobiaoQueryWrapper.like("guoji",map.get("guoji"));
        return mapper.selectList(cCarGuobiaoQueryWrapper);
    }

    @Override
    public Integer UpdateCarGuobiao(CCarGuobiao cCarGuobiao) {//修改
        UpdateWrapper<CCarGuobiao> cCarGuobiaoUpdateWrapper = new UpdateWrapper<>();
        cCarGuobiaoUpdateWrapper.eq("id",cCarGuobiao.getId());
        return mapper.update(cCarGuobiao,cCarGuobiaoUpdateWrapper);
    }

    @Override
    public Integer delCarGuobiao(CCarGuobiao cCarGuobiao) {//删除
        return mapper.deleteById(cCarGuobiao.getId());
    }

    @Override
    public CCarGuobiao queryOneGuobiao(Integer id) {
        CCarGuobiao cCarGuobiao = mapper.selectById(id);
        System.out.println("service层得到的数据为："+cCarGuobiao.getGuoji());
        return cCarGuobiao;
    }
}
